﻿using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Text.Json.Serialization;

namespace TodoListApp.Models
{
    public class TodoItem : INotifyPropertyChanged
    {
        private string _todoContent = string.Empty;
        private bool _isSelected;

        [JsonPropertyName("todo_content")]
        public string TodoContent {
            get => _todoContent;
            set
            {
                _todoContent = value;
                OnPropertyChanged();
            }
        }

        [JsonIgnore]
        public bool IsSelected
        {
            get => _isSelected;
            set
            {
                _isSelected = value;
                OnPropertyChanged();
            }
        }

        public event PropertyChangedEventHandler? PropertyChanged;
        protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
